package com.zzc.study.config;

import com.zzc.study.service.ChatAssistant;
import dev.langchain4j.model.chat.StreamingChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import dev.langchain4j.service.AiServices;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

@Configuration(proxyBeanMethods = false)
@Slf4j
public class ChatLanguageModelConfig {
    @Bean
    public StreamingChatLanguageModel streamingChatLanguageModel() {
        return  OpenAiStreamingChatModel.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .modelName("qwen-turbo-0624")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .timeout(Duration.ofSeconds(10))
                .build();
    }
    @Bean
    public ChatAssistant chatAssistant(StreamingChatLanguageModel streamingChatLanguageModel) {
        return AiServices.create(ChatAssistant.class, streamingChatLanguageModel);
    }

}
/**
 public ChatLanguageModel chatLanguageModel()
 {
 return
 OpenAiChatModel.builder()
 .apiKey(System.getenv("deepseek-api"))
 .modelName("deepseek-chat")
 //.modelName("deepseek-reasoner")
 .baseUrl("https://api.deepseek.com/v1")
 .build();
 }
 */

